<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<%@ include file="/commons/tabs.jsp" %>
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript">
	/**
	* 本窗体操作对象
	**/
	var hadChange=false;
	var currentTabId="";

	function AreaEditObj(frameId){
		this.frame = window.frames(frameId);
		/*****提交子窗体表单,所以子页面都要求用submitForm方法提交****/
		this.submit = function(closeFlag){
			this.setSaveUnClick(); //设置按钮不可用
			var flag = this.frame.submitForm(closeFlag);
		}

		/*****关闭窗体---需要检查的*******/
		this.closeWindow = function(){
			var flag = this.frame.allowClose();
			if(flag) {
				windowClose();
				return;
			}
			AskConfirmTwo('${key.tipsForCloseWindow}','areaBaseEditFrameid','closeWindowBeforSave','areaObj.closeWindowOnCheck');
		}
		/***不需做任何检查的关闭窗体*****/
		this.closeWindowOnCheck = function(){
			windowClose();
		}
		this.setIsSave = function(){
			if(this.frame.document.getElementById("isSave"))
				this.frame.document.getElementById("isSave").value = "isSave";
			if(this.frame.document.getElementById('isEdit'))
				this.frame.document.getElementById('isEdit').value = "";
		}
		/***设置按钮不可用**/
		this.setSaveUnClick =  function (){
			document.getElementById('btn1_22').disabled = true;
			document.getElementById('btn1_32').disabled = true;

		}
		/***设置按钮可用**/
		this.setSaveClick = function (){
			document.getElementById('btn1_22').disabled = false;
			document.getElementById('btn1_32').disabled = false;
		}
		//刷新父页面
		this.flushIframe = function(){
			findFrame("mainFrame").flushList();
			findFrame("main").refleshTreeForArea();
		}
	}

	function TabObject(frameId){
		this.frame = window.frames(frameId);
		/*****基本资料点击是否分期时，隐藏配套设施，参见单位******/
		this.hasProject = function(flag){
			/**分期开发，隐藏tab**/
			if(flag){
				hideTab('projectEnvironmentEdit');
				hideTab('projectJoinGrop');
			}else if(! flag){
				/**不分期开发，显示tab**/
				showTab('projectEnvironmentEdit');
				showTab('projectJoinGrop');
			}
		}
		this.flushTab = function(){
			this.frame.window.location.reload();
		}
		/****更改tab前，需要检查是否有数据更改****/
		this.befroeSwitch = function(){
			var flag = this.frame.allowSubmit();

			if(!flag){
				AskConfirm('${key.tipsForCloseWindow}','areaBaseEditFrameid','areaObj.submit');

			}
		}
	}

	/************关闭时，如果确定保存数据，则调用该方法****************/
	function closeWindowBeforSave(){
		if(areaObj.frame.document.getElementById('isEdit'))
			areaObj.frame.document.getElementById('isEdit').value = "isEdit";
		if(areaObj.frame.document.getElementById("isSave"))
			areaObj.frame.document.getElementById("isSave").value = "";
		areaObj.submit("isClose");
	}

	var areaObj = null;
	var tabOption = null;
    function init(){
		areaObj = new AreaEditObj('areaInfoIframe');
		tabOption = new TabObject('areaInfoIframe');

		<c:if test="${areavo.hasMoreProject eq 1}">
			hideTab('projectEnvironmentEdit');
			hideTab('projectJoinGrop');
		</c:if>
    }

    function validationChange(tabId){
     currentTabId=tabId;
     if(findFrame("areaInfoIframe").getChange()){
        AskConfirmTwo("xxx","areaBaseEditFrameid","saveChange","cancelChange");
        return false;
     }

    return true;

    }
    function saveChange(){
    areaObj.submit();
    cancelChange();

    }
    function cancelChange(){
    findFrame("areaInfoIframe").setChange();
    onClickTab(currentTabId);

    }

</script>
</head>
<body onload="init();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg">
    	<table border="0" cellpadding="0" cellspacing="0">
      		<tr>
        		<td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">修改楼盘资料</span></td>
        	</tr>
    	</table>
    </td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td valign="middle" class="content">
	<pms:tabPanel panelId="areaBase" hasTop="false" iframeId="areaInfoIframe" defaultHeight="350px" barWidthLeft="70%">
		<pms:tab tabId="baseInformation"
				 baseUrl="${ctx}/house_areaAction.do?method=initAreaBaseInformationEdit"
				 caption="${key.base_data}"
				 defaultTab="true"

				 beforeFunction="areaObj.setSaveClick();"
				 >
		</pms:tab>
		<pms:tab tabId="projectEnvironmentEdit"
				 baseUrl="${ctx}/house_areaAction.do?method=initAreaEnvironment"
				 caption="${key.area_Environment}"
				 beforeFunction="document.getElementById('btn1_22').disabled = true;"
				 >
		</pms:tab>
		<pms:tab tabId="projectJoinGrop"
				 baseUrl="${ctx}/house_areaAction.do?method=initAreaJoin"
				 caption="${key.join}"
				 beforeFunction="areaObj.setSaveClick();"
				 >
		</pms:tab>
		<pms:tab tabId="projectLayout"
				 baseUrl="${ctx}/house_areaAction.do?method=initAreaLayoutEdit"
				 caption="${key.area_LayoutEdit}"
				 beforeFunction="areaObj.setSaveClick();"
				 >
		</pms:tab>
		<pms:tab tabId="areaGovtRelation"
				 baseUrl="${ctx}/house_areaAction.do?method=initAreaGovtRelationEdit"
				 caption="${key.area_GovtRelation}"
				 beforeFunction="areaObj.setSaveClick();"
				 >
		</pms:tab>
	</pms:tabPanel>
	</td>
	</tr>
	<tr>
    <td class="window_footer"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0" >
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onblur="btn_change(2)" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onClick="areaObj.setIsSave();areaObj.submit('isSave');">
              	<img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> 保 存
              </td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0" >
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onblur="btn_change(3)" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onClick="areaObj.closeWindow();">
              	<img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" /> 关 闭
              </td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
	</tr>
	</table>
</body>

</script>
</html>